package cn.calm.xhtml.util;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public abstract class DateUtils {
	private static final SimpleDateFormat sdf = new SimpleDateFormat();

	public static String format(Date date, String pattern) {
		if (date == null) {
			return null;
		}
		sdf.applyPattern(pattern);
		return sdf.format(date);
	}

	public static String formatNow(String pattern) {
		Calendar instance = Calendar.getInstance();
		sdf.applyPattern(pattern);
		return sdf.format(instance.getTime());
	}
}
